package org.theqcp.wow.api.wowarmory.parsers.talents;

import java.util.ArrayList;

import org.theqcp.wow.model.api.ProgressListener;
import org.theqcp.wow.model.mechanics.ClassType;
import org.theqcp.wow.model.player.Talent;
import org.theqcp.wow.model.player.classes.shaman.ShamanTalentFactory;

public class ShamanTalentParser extends AbstractTalentParser{

	
	
	@Override
	public ArrayList<Talent> parse(int[] talents, ProgressListener listener) {
		//talent factory
		ShamanTalentFactory sft = new ShamanTalentFactory();
		
		//talent list
		ArrayList<Talent> talentList = new ArrayList<Talent>();
		
		int base = 0;
		int x = -1;
		//left to right, by row
		//elemental 0 - 23
		//250030130000000000000000
		//  0 - Convection
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Convection",talents[base + x],ClassType.SHAMAN));
		}
		//  1 - Concussion
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Concussion",talents[base + x],ClassType.SHAMAN));
		}
		//  2 - Call of Flame
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Call of Flame",talents[base + x],ClassType.SHAMAN));
		}
		//  3 - Elemental Warding
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Elemental Warding",talents[base + x],ClassType.SHAMAN));
		}
		//  4 - Elemental Devestation
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Elemental Devestation",talents[base + x],ClassType.SHAMAN));
		}
		//  5 - Reverberation 
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Reverberation",talents[base + x],ClassType.SHAMAN));
		}
		//  6 - Elemental Focus
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Elemental Focus",talents[base + x],ClassType.SHAMAN));
		}
		//  7 - Elemental Fury
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Elemental Fury",talents[base + x],ClassType.SHAMAN));
		}
		//  8 - Improved Fire Nova Totem
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Improved Fire Nova Totem",talents[base + x],ClassType.SHAMAN));
		}
		//  9 - Eye of the Storm
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Eye of the Storm",talents[base + x],ClassType.SHAMAN));
		}
		// 10 - Elemental Reach
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Elemental Reach",talents[base + x],ClassType.SHAMAN));
		}		
		// 11 - Call of Thunder
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Call of Thunder",talents[base + x],ClassType.SHAMAN));
		}
		// 12 - Unrelenting Storm
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Unrelenting Storm",talents[base + x],ClassType.SHAMAN));
		}
		// 13 - Elemental Precision
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Elemental Precision",talents[base + x],ClassType.SHAMAN));
		}		
		// 14 - Lightning Mastery
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Lightning Mastery",talents[base + x],ClassType.SHAMAN));
		}
		// 15 - Elemental Mastery
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Elemental Mastery",talents[base + x],ClassType.SHAMAN));
		}
		// 16 - Elemental Shields
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Elemental Shields",talents[base + x],ClassType.SHAMAN));
		}
		// 17 - Elemental Oath
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Elemental Oath",talents[base + x],ClassType.SHAMAN));
		}
		// 18 - Lightning Overload
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Lightning Overload",talents[base + x],ClassType.SHAMAN));
		}
		// 19 - Astral Shift
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Astral Shift",talents[base + x],ClassType.SHAMAN));
		}
		// 20 - Totem of Wrath
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Totem of Wrath",talents[base + x],ClassType.SHAMAN));
		}
		// 21 - Lava Flows 
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Lava Flows",talents[base + x],ClassType.SHAMAN));
		}
		// 22 - Storm, Earth, and Fire
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Storm, Earth, and Fire",talents[base + x],ClassType.SHAMAN));
		}
		// 23 - Thunderstorm
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Thunderstorm",talents[base + x],ClassType.SHAMAN));
		}
		
		if(listener != null) {
			listener.updateProgress(33.3, "Elemental talents complete");
		}
		
		base = 24;
		x = -1;
		//enhancement 24 - 51
		//0050520313500135331131201050
		//  0 - Enhancing Totems
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Enhancing Totems",talents[base + x],ClassType.SHAMAN));
		}
		//  1 - Earth's Grasp
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Earth's Grasp",talents[base + x],ClassType.SHAMAN));
		}
		//  2 - Ancestral Knowledge
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Ancestral Knowledge",talents[base + x],ClassType.SHAMAN));
		}		
		//  3 - Guardian Totems
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Guardian Totems",talents[base + x],ClassType.SHAMAN));
		}
		//  4 - Thundering Strikes
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Thundering Strikes",talents[base + x],ClassType.SHAMAN));
		}
		//  5 - Improved Ghost Wolf
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Improved Ghost Wolf",talents[base + x],ClassType.SHAMAN));
		}
		//  6 - Improved Shields
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Improved Shields",talents[base + x],ClassType.SHAMAN));
		}
		//  7 - Elemental Weapons
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Elemental Weapons",talents[base + x],ClassType.SHAMAN));
		}
		//  8 - Shamanistic Focus
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Shamanistic Focus",talents[base + x],ClassType.SHAMAN));
		}
		//  9 - Anticipation
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Anticipation",talents[base + x],ClassType.SHAMAN));
		}
		// 10 - Flurry
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Flurry",talents[base + x],ClassType.SHAMAN));
		}
		// 11 - Toughness
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Toughness",talents[base + x],ClassType.SHAMAN));
		}
		// 12 - Improved Windfury Totem
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Improved Windfury Totem",talents[base + x],ClassType.SHAMAN));
		}
		// 13 - Spirit Weapons
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Spirit Weapons",talents[base + x],ClassType.SHAMAN));
		}
		// 14 - Mental Dexterity
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Mental Dexterity",talents[base + x],ClassType.SHAMAN));
		}
		// 15 - Unleashed Rage
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Unleashed Rage",talents[base + x],ClassType.SHAMAN));
		}
		// 16 - Weapon Mastery
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Weapon Mastery",talents[base + x],ClassType.SHAMAN));
		}
		// 17 - Dual Wield Specialization
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Dual Wield Specialization",talents[base + x],ClassType.SHAMAN));
		}
		// 18 - Dual Wield Specialization
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Dual Wield",talents[base + x],ClassType.SHAMAN));
		}		
		// 19 - Stormstrike
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Stormstrike",talents[base + x],ClassType.SHAMAN));
		}
		// 20 - Mental Quickness
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Static Shock",talents[base + x],ClassType.SHAMAN));
		}
		// 21 - Lava Lash
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Lava Lash",talents[base + x],ClassType.SHAMAN));
		}
		// 22 - Improved Stormstrike
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Improved Stormstrike",talents[base + x],ClassType.SHAMAN));
		}
		// 23 - Static Shock
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Mental Quickness",talents[base + x],ClassType.SHAMAN));
		}
		// 24 - Shamanistic Rage
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Shamanistic Rage",talents[base + x],ClassType.SHAMAN));
		}
		// 25 - Earthen Power
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Earthen Power",talents[base + x],ClassType.SHAMAN));
		}
		// 26 - Maelstrom Weapon
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Maelstrom Weapon",talents[base + x],ClassType.SHAMAN));
		}
		// 27 - Feral Spirit
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Feral Spirit",talents[base + x],ClassType.SHAMAN));
		}
		
		if(listener != null) {
			listener.updateProgress(66.6, "Enhancement talents complete");
		}
		
		base = 52;
		x = -1;
		//restoration 52 - 77
		//30000000000000000000000000
		//  0 - Improved Healing Wave
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Improved Healing Wave",talents[base + x],ClassType.SHAMAN));
		}		
		//  1 - Totemic Focus
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Totemic Focus",talents[base + x],ClassType.SHAMAN));
		}
		//  2 - Improved Reincarnation
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Improved Reincarnation",talents[base + x],ClassType.SHAMAN));
		}		
		//  3 - Ancestral Healing
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Ancestral Healing",talents[base + x],ClassType.SHAMAN));
		}
		//  4 - Tidal Focus
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Tidal Focus",talents[base + x],ClassType.SHAMAN));
		}		
		//  5 - Improved Water Shield
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Improved Water Shield",talents[base + x],ClassType.SHAMAN));
		}
		//  6 - Healing Focus
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Healing Focus",talents[base + x],ClassType.SHAMAN));
		}
		//  7 - Tidal Force
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Tidal Force",talents[base + x],ClassType.SHAMAN));
		}
		//  8 - Healing Grace
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Healing Grace",talents[base + x],ClassType.SHAMAN));
		}
		//  9 - Restorative Totems
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Restorative Totems",talents[base + x],ClassType.SHAMAN));
		}
		// 10 - Tidal Mastery
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Tidal Mastery",talents[base + x],ClassType.SHAMAN));
		}
		// 11 - Healing Way
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Healing Way",talents[base + x],ClassType.SHAMAN));
		}
		// 12 - Nature's Swiftness
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Nature's Swiftness",talents[base + x],ClassType.SHAMAN));
		}
		// 13 - Focused Mind
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Focused Mind",talents[base + x],ClassType.SHAMAN));
		}
		// 14 - Purification
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Purification",talents[base + x],ClassType.SHAMAN));
		}
		// 15 - Nature's Guardian
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Nature's Guardian",talents[base + x],ClassType.SHAMAN));
		}
		// 16 - Mana Tide Totem
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Mana Tide Totem",talents[base + x],ClassType.SHAMAN));
		}
		// 17 - Cleanse Spirit
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Cleanse Spirit",talents[base + x],ClassType.SHAMAN));
		}
		// 18 - Blessing of the Eternals
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Blessing of the Eternals",talents[base + x],ClassType.SHAMAN));
		}
		// 19 - Improved Chain Heal
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Improved Chain Heal",talents[base + x],ClassType.SHAMAN));
		}
		// 20 - Nature's Blessing
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Nature's Blessing",talents[base + x],ClassType.SHAMAN));
		}
		// 21 - Ancestral Awakening
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Ancestral Awakening",talents[base + x],ClassType.SHAMAN));
		}
		// 22 - Earth Shield
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Earth Shield",talents[base + x],ClassType.SHAMAN));
		}
		// 23 - Improved Earth Shield
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Improved Earth Shield",talents[base + x],ClassType.SHAMAN));
		}
		// 24 - Tidal Waves
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Tidal Waves",talents[base + x],ClassType.SHAMAN));
		}
		// 25 - Riptide
		if(talents[base + ++x] > 0) {
			talentList.add(sft.createTalent("Riptide",talents[base + x],ClassType.SHAMAN));
		}
		
		if(listener != null) {
			listener.updateProgress(100.0, "Restoration talents complete");
		}
		
		//return talents
		return talentList;
	}	
	
}
